﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using DomusDotNet.Sbm.Client.SL4noCM.WCFServices;
using System.Windows.Media.Imaging;

namespace DomusDotNet.Sbm.Client.SL4noCM.Converters
{
    public class BookStatusConverter:IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is  BookStatus)
            {
                var parSplit = parameter.ToString().Split(';');
                switch ((BookStatus)value)
                {
                    case BookStatus.Available:
                        return (parSplit.Length==0 ? null : parSplit[0]);
                    case BookStatus.OnLoan :
                        return (parSplit.Length<1 ? null : parSplit[1]);
                    case BookStatus.Booked:
                        return (parSplit.Length < 2 ? null : parSplit[2]);
                    default:
                        return null;
                }
            }
            else
            {
                return "";
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
